package com.ruoyi.web.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.SuperGroupProduct;
import com.ruoyi.system.service.ISuperGroupProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 拼团列表Controller
 * 
 * @author xjf
 * @date 2025-08-14
 */
@RestController
@RequestMapping("/activity/groupproduct")
public class SuperGroupProductController extends BaseController
{
    @Autowired
    private ISuperGroupProductService superGroupProductService;

    /**
     * 查询拼团列表列表
     */
    @PreAuthorize("@ss.hasPermi('activity:groupproduct:list')")
    @GetMapping("/list")
    public TableDataInfo list(SuperGroupProduct superGroupProduct)
    {
        startPage();
        List<SuperGroupProduct> list = superGroupProductService.selectSuperGroupProductList(superGroupProduct);
        return getDataTable(list);
    }

    /**
     * 导出拼团列表列表
     */
    @PreAuthorize("@ss.hasPermi('activity:groupproduct:export')")
    @Log(title = "拼团列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SuperGroupProduct superGroupProduct)
    {
        List<SuperGroupProduct> list = superGroupProductService.selectSuperGroupProductList(superGroupProduct);
        ExcelUtil<SuperGroupProduct> util = new ExcelUtil<SuperGroupProduct>(SuperGroupProduct.class);
        util.exportExcel(response, list, "拼团列表数据");
    }

    /**
     * 获取拼团列表详细信息
     */
    @PreAuthorize("@ss.hasPermi('activity:groupproduct:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(superGroupProductService.selectSuperGroupProductById(id));
    }

    /**
     * 新增拼团列表
     */
    @PreAuthorize("@ss.hasPermi('activity:groupproduct:add')")
    @Log(title = "拼团列表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SuperGroupProduct superGroupProduct)
    {
        return toAjax(superGroupProductService.insertSuperGroupProduct(superGroupProduct));
    }

    /**
     * 修改拼团列表
     */
    @PreAuthorize("@ss.hasPermi('activity:groupproduct:edit')")
    @Log(title = "拼团列表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SuperGroupProduct superGroupProduct)
    {
        return toAjax(superGroupProductService.updateSuperGroupProduct(superGroupProduct));
    }

    /**
     * 删除拼团列表
     */
    @PreAuthorize("@ss.hasPermi('activity:groupproduct:remove')")
    @Log(title = "拼团列表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(superGroupProductService.deleteSuperGroupProductByIds(ids));
    }
}
